<?php
/**
 *    Copyright 2010 Show Framework(www.showframework.cn)
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 * 
 *        http://www.apache.org/licenses/LICENSE-2.0
 * 
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

/**
 * 去除slashes -- 可以递归的去除array里面的每个元素的slashes
 * 可以用此过滤类去除$_GET, $_POST, $_COOKIE 的slashes
 * 此类不做get_magic_quote_gpc的检查了
 * 关于gpc的处理，看个人觉悟了
 * addslashes mysql_escape_string mysql_real_escape_string 的关系看个人觉悟了
 * 以后有可能，会在框架添加其他专用于gpc的过滤类
 * php6中 会去掉自动slashes的支持，现在一般的设置也是关闭的，我不管了
 * 
 * @package Show_Filter
 * @name Show_Filter_Stripslashes
 * @author show
 * @since v0.6
 */
class Show_Filter_Stripslashes implements Show_Filter_Interface
{
    /**
     * 过滤
     *
     * @param mixed $value
     * @return mixed
     */
    public function filter($value = null)
    {
        array_walk_recursive($value, 'Show_Filter_Stripslashes::_stripslashes');
        return $value;
    }
    
    /**
     * 去除转义
     *
     * @param string $item
     * @param string $key
     * @return void
     */
    public static function _stripslashes(&$item, $key)
    {
        $item = stripslashes($item);
    }
}
?>